<h4 class="h4"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>&nbsp;添加管理员</h4>
<form class="form-horizontal" method="post" id="tj" action="comm/addadmin.php">
    <div class="form-group">
        <label for="username" class="col-sm-2 control-label">用户名</label>
        <div class="col-sm-3">
            <input type="text" class="form-control" id="username" placeholder="用户名" name="name">
        </div>
    </div>
    <div class="form-group">
        <label for="password" class="col-sm-2 control-label">密码</label>
        <div class="col-sm-3">
            <input type="password" class="form-control" id="password" placeholder="密码" name="password">
        </div>
    </div>
    <div class="form-group">
        <label for="repassword" class="col-sm-2 control-label">确认密码</label>
        <div class="col-sm-3">
            <input type="password" class="form-control" id="repassword" placeholder="确认密码" name="repassword">
        </div>
    </div>

    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-ok"
                    aria-hidden="true"></span>&nbsp;提交
            </button>
        </div>
    </div>
</form>
<script>
    $('#tj').on('submit', function () {
        console.log($(this).serializeArray())
        if (!$(this).serializeArray()[0].value) {
            layer.msg('用户名不能为空!', { icon: 5, time: 1000, offset: '550px', anim: 6 });
            return false;
        }
        if (!$(this).serializeArray()[1].value) {
            layer.msg('密码不能为空!', { icon: 5, time: 1000, offset: '550px', anim: 6 });
            return false;
        }
        if (!$(this).serializeArray()[2].value) {
            layer.msg('确认密码不能为空!', { icon: 5, time: 1000, offset: '550px', anim: 6 });
            return false;
        }
        if($(this).serializeArray()[2].value!=$(this).serializeArray()[1].value){
            layer.msg('输入的两次密码不同!', { icon: 5, time: 1000, offset: '550px', anim: 6 });
            return false;
        }
        return true;
    })
</script>